<!DOCTYPE html>
<html>
<head><meta charset="utf-8">
    <meta content="webkit" name="renderer"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <meta http-equiv="Expires" content="0"/>
    <meta content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
    <title>药店管理系统</title>
    <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"/>
    <script src="js/jquery/jquery-1.12.4.min.js"></script>
    <!--[if lt IE 9]><script src="js/common/h5fix.min.js"></script><![endif]-->
    <link rel="stylesheet" href="css/fonts/font-icons.min.css">
    <link rel="stylesheet" href="js/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="js/adminlte/css/AdminLTE.min.css">
    <link rel="stylesheet" href="css/jsherp.css">
    <link rel="stylesheet" href="js/adminlte/css/skins/skin-blue-light2.css">
</head><body class="hold-transition ">
<div class="wrapper">
    <div class="content pb0">
        <div class="row">
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-aqua"><i class="fa fa-shopping-bag"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">今日累计销售</span>
                        <span id="todaySale" class="info-box-number"></span>
                    </div>
                </div>
            </div>
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-red"><i class="fa fa-shopping-cart"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">本月累计销售</span>
                        <span id="thisMonthSale" class="info-box-number"></span>
                    </div>
                </div>
            </div>
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-green"><i class="fa fa-suitcase"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">今日累计进货</span>
                        <span id="todayBuy" class="info-box-number"></span>
                    </div>
                </div>
            </div>
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-yellow"><i class="fa fa-shopping-basket"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">本月累计进货</span>
                        <span id="thisMonthBuy" class="info-box-number"></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <section class="col-md-6 ui-sortable">
                <div class="box box-solid">
                    <div class="box-header ui-sortable-handle">
                        <i class="fa fa-th"></i>
                        <h3 class="box-title">采购统计</h3>
                        <div class="box-tools pull-right"></div>
                    </div>
                    <div class="box-body border-radius-none">
                        <div id="buyIn" style="min-width:400px;height:380px"></div>
                    </div>
                </div>
            </section>
            <section class="col-md-6 ui-sortable ui-sortable">
                <div class="box box-solid">
                    <div class="box-header ui-sortable-handle">
                        <i class="fa fa-th"></i>
                        <h3 class="box-title">销售统计</h3>
                        <div class="box-tools pull-right"></div>
                    </div>
                    <div class="box-body border-radius-none">
                        <div id="saleOut" style="min-width:400px;height:380px"></div>
                    </div>
                </div>
            </section>
        </div>
    </div>
    <footer class="main-footer m0">
        <div class="pull-right hidden-xs">当前版本： V2.1</div>
        &copy; 2024-2030 药店管理系统 - Powered By <a href="" target="_blank">官方网站</a>
    </footer>
</div>

<a id="scroll-up" href="#" class="btn btn-sm"><i class="fa fa-angle-double-up"></i></a>
<script src="js/layer/3.1/layer.js"></script>
<script src="js/common/jsherp.js"></script>
<script src="js/common/common.js"></script>
<script src="js/common/i18n/jsherp_zh_CN.js"></script>
<script>
    if ($('#switchSkin').length > 0){
        $('#switchSkin i').addClass('jump5');
        setTimeout(function(){
            $('.main-sidebar [title="角色管理"]').append('<span class="pull-right-container">'
                +'<small class="label pull-right bg-red jump">hot</small></span>');
        },2000);
    }
</script>
<script src="js/jquery/jquery-ui-sortable-1.12.1.min.js"></script>
<script src="js/highcharts/highcharts.js"></script>
<script src="js/highcharts/exporting.js"></script>
<script src="js/highcharts/highcharts-zh_CN.js"></script>
<script>
    $(window).resize(function(){
        var footerHeight  = $('.main-footer').outerHeight() || 0;
        var windowHeight  = $(window).height();
        $('.content').css('min-height', windowHeight - footerHeight)
    }).resize();
    $('.ui-sortable').sortable({
        placeholder         : 'sort-highlight',
        connectWith         : '.ui-sortable',
        handle              : '.box-header, .nav-tabs',
        forcePlaceholderSize: true,  zIndex : 999999
    }).find('.box-header, .nav-tabs').css('cursor', 'move');

    $(function () {
        var loginName = sessionStorage.getItem("loginName");
        if(loginName!="admin") {
            $.ajax({
                type: "get",
                url: "/depotHead/getBuyAndSaleStatistics",
                dataType: "json",
                success: function (res) {
                    if (res && res.code === 200) {
                        if (res.data) {
                            $("#todaySale").text((res.data.todaySale).toFixed(2));
                            $("#todayBuy").text((res.data.todayBuy).toFixed(2));
                            $("#thisMonthSale").text((res.data.thisMonthSale).toFixed(2));
                            $("#thisMonthBuy").text((res.data.thisMonthBuy).toFixed(2));
                        }
                    }
                },
                error: function (res) {

                }
            });
        } else {
            $("#todaySale").text("--");
            $("#todayBuy").text("--");
            $("#thisMonthSale").text("--");
            $("#thisMonthBuy").text("--");
        }
    });

    function getChartObj(titleName, categories, seriesData) {
        var chartObj = {
            chart: {
                type: 'spline'
            },
            title: {
                text: titleName
            },
            xAxis: {
                categories: categories
            },
            yAxis: {
                title: {
                    text: '金额（元）'
                }
            },
            series: [{
                name: titleName,
                data: seriesData
            }]
        }
        return chartObj;
    }
    $(function () {
        var loginName = sessionStorage.getItem("loginName");
        if(loginName!="admin") {
            $.ajax({
                type: "get",
                url: "/depotItem/buyOrSalePrice",
                dataType: "json",
                success: function (res) {
                    if (res && res.code === 200) {
                        var data = res.data;
                        Highcharts.chart('buyIn', getChartObj("最近6个月采购数据", res.data.monthList, res.data.buyPriceList));
                        Highcharts.chart('saleOut', getChartObj("最近6个月销售数据", res.data.monthList, res.data.salePriceList));
                    }
                },
                error: function (res) {

                }
            });
        } else {
            Highcharts.chart('buyIn', getChartObj("最近6个月采购数据", [], []));
            Highcharts.chart('saleOut', getChartObj("最近6个月销售数据", [], []));
        }
    });

</script>
